




/*
'===============================================================================
'  HNG.Portal.BL.TblRoleManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using HNG.Portal.BLL;
using HNG.Portal.DAL;
using HNG.Portal.DAL.EntityClasses;
using HNG.Portal.DAL.FactoryClasses;
using HNG.Portal.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Windows.Forms;
namespace HNG.Portal.BLL
{
	public class TblRoleManagerBase
	{
	    
		#region ColumnNames
		
				public const String Field_Id="Id";
				
				public const String Field_TenNhomQuyen="TenNhomQuyen";
				
				public const String Field_BtnThem="BtnThem";
				
				public const String Field_BtnSua="BtnSua";
				
				public const String Field_BtnXoa="BtnXoa";
				
				public const String Field_BtnCapNhat="BtnCapNhat";
				
				public const String Field_BtnLuuLai="BtnLuuLai";
				
				public const String Field_BtnRefesh="BtnRefesh";
				
				public const String Field_BtnBack="BtnBack";
				
				public const String Field_BtnSearch="BtnSearch";
				
				public const String Field_BtnView="BtnView";
				
				public const String Field_TrangThai="TrangThai";
				
		#endregion	
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public TblRoleManagerBase()
		{
			// Nothing for now.
		}
		public DataTable Clone()
		{
			DataTable dt = new DataTable();
						
			
			dt.Columns.Add(Field_Id,typeof(int));
			
						
			
			dt.Columns.Add(Field_TenNhomQuyen,typeof(string));
			
						
			
			dt.Columns.Add(Field_BtnThem,typeof(bool));
			
						
			
			dt.Columns.Add(Field_BtnSua,typeof(bool));
			
						
			
			dt.Columns.Add(Field_BtnXoa,typeof(bool));
			
						
			
			dt.Columns.Add(Field_BtnCapNhat,typeof(bool));
			
						
			
			dt.Columns.Add(Field_BtnLuuLai,typeof(bool));
			
						
			
			dt.Columns.Add(Field_BtnRefesh,typeof(bool));
			
						
			
			dt.Columns.Add(Field_BtnBack,typeof(bool));
			
						
			
			dt.Columns.Add(Field_BtnSearch,typeof(bool));
			
						
			
			dt.Columns.Add(Field_BtnView,typeof(bool));
			
						
			
			dt.Columns.Add(Field_TrangThai,typeof(bool));
			
			            
            return dt;			
		}
			
		public TblRoleEntity Convert_Entity(TblRoleEntity _TblRoleEntity,TblRoleEntity _TblRoleEntity_XML)
		{	
			
				
			_TblRoleEntity.Id= _TblRoleEntity_XML.Id;
				
			_TblRoleEntity.TenNhomQuyen= _TblRoleEntity_XML.TenNhomQuyen;
				
			_TblRoleEntity.BtnThem= _TblRoleEntity_XML.BtnThem;
				
			_TblRoleEntity.BtnSua= _TblRoleEntity_XML.BtnSua;
				
			_TblRoleEntity.BtnXoa= _TblRoleEntity_XML.BtnXoa;
				
			_TblRoleEntity.BtnCapNhat= _TblRoleEntity_XML.BtnCapNhat;
				
			_TblRoleEntity.BtnLuuLai= _TblRoleEntity_XML.BtnLuuLai;
				
			_TblRoleEntity.BtnRefesh= _TblRoleEntity_XML.BtnRefesh;
				
			_TblRoleEntity.BtnBack= _TblRoleEntity_XML.BtnBack;
				
			_TblRoleEntity.BtnSearch= _TblRoleEntity_XML.BtnSearch;
				
			_TblRoleEntity.BtnView= _TblRoleEntity_XML.BtnView;
				
			_TblRoleEntity.TrangThai= _TblRoleEntity_XML.TrangThai;
				
			
			return _TblRoleEntity;
		}	
		
			
		public void InsertCollection(EntityCollection _Collection)
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {
                adapter.SaveEntityCollection(_Collection);
            }
		}

		public TblRoleEntity Insert(TblRoleEntity TblRoleEntity)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(TblRoleEntity, true);
			}
			return TblRoleEntity;
		}

		
		public TblRoleEntity Insert(int Id, string TenNhomQuyen, bool BtnThem, bool BtnSua, bool BtnXoa, bool BtnCapNhat, bool BtnLuuLai, bool BtnRefesh, bool BtnBack, bool BtnSearch, bool BtnView, bool TrangThai)
		{
			TblRoleEntity _TblRoleEntity = new TblRoleEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblRoleEntity.Id = Id;
				_TblRoleEntity.TenNhomQuyen = TenNhomQuyen;
				_TblRoleEntity.BtnThem = BtnThem;
				_TblRoleEntity.BtnSua = BtnSua;
				_TblRoleEntity.BtnXoa = BtnXoa;
				_TblRoleEntity.BtnCapNhat = BtnCapNhat;
				_TblRoleEntity.BtnLuuLai = BtnLuuLai;
				_TblRoleEntity.BtnRefesh = BtnRefesh;
				_TblRoleEntity.BtnBack = BtnBack;
				_TblRoleEntity.BtnSearch = BtnSearch;
				_TblRoleEntity.BtnView = BtnView;
				_TblRoleEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblRoleEntity, true);
			}
			return _TblRoleEntity;
		}

		public TblRoleEntity Insert(string TenNhomQuyen, bool BtnThem, bool BtnSua, bool BtnXoa, bool BtnCapNhat, bool BtnLuuLai, bool BtnRefesh, bool BtnBack, bool BtnSearch, bool BtnView, bool TrangThai)
		{
			TblRoleEntity _TblRoleEntity = new TblRoleEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblRoleEntity.TenNhomQuyen = TenNhomQuyen;
				_TblRoleEntity.BtnThem = BtnThem;
				_TblRoleEntity.BtnSua = BtnSua;
				_TblRoleEntity.BtnXoa = BtnXoa;
				_TblRoleEntity.BtnCapNhat = BtnCapNhat;
				_TblRoleEntity.BtnLuuLai = BtnLuuLai;
				_TblRoleEntity.BtnRefesh = BtnRefesh;
				_TblRoleEntity.BtnBack = BtnBack;
				_TblRoleEntity.BtnSearch = BtnSearch;
				_TblRoleEntity.BtnView = BtnView;
				_TblRoleEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblRoleEntity, true);
			}
			return _TblRoleEntity;
		}

		public bool Update(TblRoleEntity _TblRoleEntity)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(TblRoleFields.Id == _TblRoleEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_TblRoleEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}
		
		public bool Update(TblRoleEntity _TblRoleEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_TblRoleEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}

		public bool Update(int Id, string TenNhomQuyen, bool BtnThem, bool BtnSua, bool BtnXoa, bool BtnCapNhat, bool BtnLuuLai, bool BtnRefesh, bool BtnBack, bool BtnSearch, bool BtnView, bool TrangThai)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblRoleEntity _TblRoleEntity = new TblRoleEntity(Id);
				if (adapter.FetchEntity(_TblRoleEntity))
				{
				
					_TblRoleEntity.TenNhomQuyen = TenNhomQuyen;
					_TblRoleEntity.BtnThem = BtnThem;
					_TblRoleEntity.BtnSua = BtnSua;
					_TblRoleEntity.BtnXoa = BtnXoa;
					_TblRoleEntity.BtnCapNhat = BtnCapNhat;
					_TblRoleEntity.BtnLuuLai = BtnLuuLai;
					_TblRoleEntity.BtnRefesh = BtnRefesh;
					_TblRoleEntity.BtnBack = BtnBack;
					_TblRoleEntity.BtnSearch = BtnSearch;
					_TblRoleEntity.BtnView = BtnView;
					_TblRoleEntity.TrangThai = TrangThai;
					adapter.SaveEntity(_TblRoleEntity, true);
					toReturn = true;
				}
			}
			return toReturn;
		}

		public bool Delete(int Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblRoleEntity _TblRoleEntity = new TblRoleEntity(Id);
				if (adapter.FetchEntity(_TblRoleEntity))
				{
					adapter.DeleteEntity(_TblRoleEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("TblRoleEntity", null);
			}
		}
		
		
		public int DeleteById(int Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTenNhomQuyen(string TenNhomQuyen)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.TenNhomQuyen == TenNhomQuyen);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBtnThem(bool BtnThem)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnThem == BtnThem);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBtnSua(bool BtnSua)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnSua == BtnSua);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBtnXoa(bool BtnXoa)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnXoa == BtnXoa);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBtnCapNhat(bool BtnCapNhat)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnCapNhat == BtnCapNhat);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBtnLuuLai(bool BtnLuuLai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnLuuLai == BtnLuuLai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBtnRefesh(bool BtnRefesh)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnRefesh == BtnRefesh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBtnBack(bool BtnBack)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnBack == BtnBack);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBtnSearch(bool BtnSearch)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnSearch == BtnSearch);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBtnView(bool BtnView)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnView == BtnView);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTrangThai(bool TrangThai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblRoleEntity", filter);
			}
			return toReturn;
		}
		

		
		public TblRoleEntity SelectOne(int Id)
		{
			TblRoleEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblRoleEntity _TblRoleEntity = new TblRoleEntity(Id);
				if (adapter.FetchEntity(_TblRoleEntity))
				{
					toReturn = _TblRoleEntity;
				}
			}
			return toReturn;
		}

		// Return EntityCollection
		public EntityCollection SelectAll()
		{
			EntityCollection _TblRoleCollection = new EntityCollection( new TblRoleEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, null, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}

		
		// Return EntityCollection
		public EntityCollection SelectById(int Id)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(int Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTenNhomQuyen(string TenNhomQuyen)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.TenNhomQuyen == TenNhomQuyen);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTenNhomQuyenRDT(string TenNhomQuyen)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.TenNhomQuyen == TenNhomQuyen);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBtnThem(bool BtnThem)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnThem == BtnThem);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBtnThemRDT(bool BtnThem)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnThem == BtnThem);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBtnSua(bool BtnSua)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnSua == BtnSua);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBtnSuaRDT(bool BtnSua)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnSua == BtnSua);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBtnXoa(bool BtnXoa)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnXoa == BtnXoa);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBtnXoaRDT(bool BtnXoa)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnXoa == BtnXoa);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBtnCapNhat(bool BtnCapNhat)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnCapNhat == BtnCapNhat);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBtnCapNhatRDT(bool BtnCapNhat)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnCapNhat == BtnCapNhat);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBtnLuuLai(bool BtnLuuLai)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnLuuLai == BtnLuuLai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBtnLuuLaiRDT(bool BtnLuuLai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnLuuLai == BtnLuuLai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBtnRefesh(bool BtnRefesh)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnRefesh == BtnRefesh);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBtnRefeshRDT(bool BtnRefesh)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnRefesh == BtnRefesh);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBtnBack(bool BtnBack)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnBack == BtnBack);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBtnBackRDT(bool BtnBack)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnBack == BtnBack);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBtnSearch(bool BtnSearch)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnSearch == BtnSearch);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBtnSearchRDT(bool BtnSearch)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnSearch == BtnSearch);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByBtnView(bool BtnView)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnView == BtnView);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBtnViewRDT(bool BtnView)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.BtnView == BtnView);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTrangThai(bool TrangThai)
		{
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblRoleCollection, filter, 0, null);
			}
			return _TblRoleCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTrangThaiRDT(bool TrangThai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblRoleCollection = new EntityCollection(new TblRoleEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblRoleFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblRoleCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		

	}
}
